<template>
    <div class="table">
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item><i class="el-icon-lx-cascades"></i> 物价文件管理</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
            <el-form ref="form" :model="form" label-width="110px" label-position="left" >
                <el-row :gutter="20">
                    <el-col :span="12"><div class="grid-content bg-purple">
                        <el-form-item label="计价器厂商名称">
                            <el-select class="handle-select" v-model="form.factname" clearable filterable placeholder="请选择" @change="currentSel">
                                <el-option
                                        v-for="item in factnameselectList"
                                        :key="item.id"
                                        :label="item.factname"
                                        :value="item.factname"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="计价器型号">
                            <el-select class="handle-select" v-model="form.jjqtype" clearable filterable placeholder="请选择">
                                <el-option
                                        v-for="item in jjqtypeselectList"
                                        :key="item.id"
                                        :label="item.jjqtype"
                                        :value="item.jjqtype"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="价格类别">
                            <el-select class="handle-select" v-model="form.pricetype" clearable filterable  placeholder="请选择">
                                <el-option
                                        v-for="item in pricetypeselectList"
                                        :key="item.id"
                                        :label="item.pricetype"
                                        :value="item.pricetype"
                                ></el-option>
                            </el-select>
                        </el-form-item>

                    </div></el-col>
                    <el-col :span="12"><div class="grid-content bg-purple-light">
                        <el-form-item label="物价文件编号">
                            <el-input class="handle-input" style="margin-left: 2.4%" clearable v-model="form.pricefileno"></el-input>
                        </el-form-item>

                        <el-form-item label="添加时间段">
                            <el-col :span="11">
                                <el-date-picker type="datetime" placeholder="选择起始时间" v-model="form.stimel" style="width: 100%;" ></el-date-picker>
                            </el-col>
                            <el-col class="line" :span="2">-</el-col>
                            <el-col :span="11">
                                <el-date-picker  type="datetime" placeholder="选择结束时间" v-model="form.stimer" style="width: 100%;"></el-date-picker>
                            </el-col>
                        </el-form-item>

                        <el-button type="primary" icon="delete" style="margin-left: 28%" class="mr10" @click="search">查询</el-button>
                        <el-button type="primary" icon="delete" class="mr10" @click="all">显示全部</el-button>
                        <el-button type="primary" icon="search" class="mr10"  @click="handleAdd()" >新增</el-button>
                        <!--<el-button type="primary" icon="search" class="mr10" v-if="canlooklog" @click="looklog()" >查看日志</el-button>-->


                    </div>
                    </el-col>
                </el-row>

                <!-- 新增弹出框 -->
                <el-dialog title="新增" :visible.sync="addVisible" width="37%"  >
                    <el-form ref="form2" :model="form2"   label-width="125px" label-position="left" padding-left="5%">
                        <el-form-item label="计价器厂商名称" prop="factid" :rules="[
                {required:true,message:'计价器厂商名称不能为空'}
                ]">
                            <el-select class="handle-select" v-model="form2.factid" clearable placeholder="请选择" @change="currentSel_add">
                                <el-option
                                        v-for="item in factnameselectList"
                                        :key="item.id"
                                        :label="item.factname"
                                        :value="item.id"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="计价器型号" prop="jjqtypeid" :rules="[
                {required:true,message:'计价器型号不能为空'}
                ]">
                            <el-select class="handle-select" v-model="form2.jjqtypeid" clearable placeholder="请选择">
                                <el-option
                                        v-for="item in jjqtypeselectList"
                                        :key="item.id"
                                        :label="item.jjqtype"
                                        :value="item.id"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="价格类别"  prop="priceid" :rules="[
                {required:true,message:'价格类别不能为空'}
                ]">
                            <el-select class="handle-select" v-model="form2.priceid" clearable placeholder="请选择">
                                <el-option
                                        v-for="item in pricetypeselectList"
                                        :key="item.id"
                                        :label="item.pricetype"
                                        :value="item.id"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="物价文件编号"  prop="pricefileno" :rules="[
                {required:true,message:'物价文件编号不能为空'}
                ]">
                            <el-input class="handle-input" clearable v-model="form2.pricefileno"></el-input>
                        </el-form-item>
                        <el-form-item label="版本号"  prop="version" :rules="[
                {required:true,message:'版本号不能为空'}
                ]">
                            <el-input class="handle-input" clearable v-model="form2.version"></el-input>
                        </el-form-item>
                        <el-form-item label="参数文件"prop="fileid" :rules="[
                {required:true,message:'参数文件不能为空'}
                ]">
                            <input type="file" @change="getFile($event)"  ref="pathClear"  accept=".bin">
                            <button @click="submitForm($event)">提交</button>
                        </el-form-item>

                        <el-form-item label="备注">
                            <el-input type="textarea" rows="5" v-model="form2.memo"></el-input>
                        </el-form-item>

                    </el-form>
                    <span slot="footer" class="dialog-footer">
                <el-button @click="addVisible = false">取 消</el-button>
                <el-button type="primary" v-loading="addLoading" @click="addParamfile(form2)">确 定</el-button>
            </span>
                </el-dialog>



                <!-- 日志弹出框 -->
                <el-dialog title="物价文件管理日志" :visible.sync="logVisible" width="80%"  >
                    <el-form ref="form2" :model="form6"   label-width="125px" label-position="left" padding-left="5%">
                        <el-row>
                            <el-col :span="12"><div class="grid-content bg-purple">
                                <el-form-item label="操作用户">
                                    <el-select class="handle-select" v-model="form6.username" clearable placeholder="请选择" @change="currentSel_add">
                                        <el-option
                                                v-for="item in usernameselectList"
                                                :key="item.id"
                                                :label="item.username"
                                                :value="item.username"
                                        ></el-option>
                                    </el-select>
                                </el-form-item>


                            </div></el-col>
                            <el-col :span="12"><div class="grid-content bg-purple-light">
                                <el-form-item label="操作类型">
                                    <el-select class="handle-select" v-model="form6.opertype" clearable placeholder="请选择">
                                        <el-option key="1" label="添加" value="1"></el-option>
                                        <el-option key="2" label="修改" value="2"></el-option>
                                        <el-option key="3" label="审核" value="3"></el-option>
                                    </el-select>
                                </el-form-item>
                                <el-button type="primary" icon="delete" style="margin-left: 30%" class="mr10" @click="searchlog">查询</el-button>
                                <el-button type="primary" icon="delete" class="mr10" @click="alllog">显示全部</el-button>
                            </div></el-col>
                        </el-row>

                        <el-table :data="logData" border  v-loading="logLoading" class="table"  stripe>
                            <el-table-column prop="username" label="操作用户" >
                            </el-table-column>
                            <el-table-column prop="opertype" label="操作方式" >
                                <template slot-scope="scope">
                                    <el-label type="text" size="small"  v-if="scope.row.opertype==1">添加</el-label>
                                    <el-label  type="text "   size="small" v-if="scope.row.opertype==2">修改</el-label>
                                    <el-label  type="text "   size="small" v-if="scope.row.opertype==3">审核</el-label>

                                </template>
                            </el-table-column>
                            <el-table-column prop="opertime" label="操作时间" >
                            </el-table-column>
                            <el-table-column prop="opercontent" label="操作内容" >
                            </el-table-column>
                        </el-table>
                        <el-col :span="24" class="toolbar pageBar">
                            <el-pagination
                                    @size-change="handleSizeChange1"
                                    @current-change="handleCurrentChange1"
                                    :current-page="currentPage1"
                                    :page-sizes="[10, 20, 30, 40]"
                                    :page-size="pageSize1"
                                    layout=" prev, pager, next, sizes, total"
                                    :total="total1">
                            </el-pagination>
                        </el-col>
                    </el-form>
                    <span slot="footer" class="dialog-footer">
                <el-button @click="logVisible = false">关 闭</el-button>
                <!--<el-button type="primary" @click="addParamfile(form2)">确 定</el-button>-->
            </span>
                </el-dialog>


            </el-form>
            <el-table :data="tableData" border  v-loading="listLoading" class="table"  stripe>
                <el-table-column prop="factname" width="120" label="计价器厂商名称" >
                </el-table-column>
                <el-table-column prop="jjqtype" label="计价器型号" >
                </el-table-column>
                <el-table-column prop="pricetype" label="价格类别" >
                </el-table-column>
                <el-table-column prop="filename" label="文件名" >
                </el-table-column>
                <el-table-column prop="pricefileno" label="物价文件编号" >
                </el-table-column>
                <el-table-column prop="stime" label="添加时间" >
                </el-table-column>
                <el-table-column prop="trafficcheck" label="交通局审核" >
                    <template slot-scope="scope">
                        <el-button  type="text"  size="small"  v-if="scope.row.trafficcheck==1">已审核</el-button>
                        <el-button  type="text" style="color: #ff4d51" size="small" v-else="scope.row.trafficcheck==0">未审核</el-button>
                    </template>
                </el-table-column>
                <el-table-column prop="pricecheck" label="物价局审核" >
                    <template slot-scope="scope">
                        <el-button type="text" size="small"  v-if="scope.row.pricecheck==1">已审核</el-button>
                        <el-button  type="text " style="color: #ff4d51" size="small" v-else="scope.row.pricecheck==0">未审核</el-button>
                    </template>
                </el-table-column>
                <el-table-column prop="metrologycheck" label="计量局审核" >
                    <template slot-scope="scope">
                        <el-button type="text" size="small"  v-if="scope.row.metrologycheck==1">已审核</el-button>
                        <el-button  type="text "  style="color: #ff4d51" size="small" v-else="scope.row.metrologycheck==0">未审核</el-button>

                    </template>
                </el-table-column>
                <el-table-column prop="writeuser" label="录入用户" >
                </el-table-column>
                <el-table-column prop="memo" label="备注" >
                </el-table-column>
                <el-table-column label="操作" width="200" align="center">
                    <template slot-scope="scope">
                        <el-button type="text" icon="el-icon-edit" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
                        <el-button type="text" icon="el-icon-delete" class="red" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
                        <el-button type="text" icon="el-icon-search"  v-if="canlooklog" @click="looklog(scope.$index, scope.row)">查看日志</el-button>

                    </template>
                </el-table-column>
            </el-table>
            <el-col :span="24" class="toolbar pageBar">
                <el-pagination
                        @size-change="handleSizeChange"
                        @current-change="handleCurrentChange"
                        :current-page="currentPage"
                        :page-sizes="[10, 20, 30, 40]"
                        :page-size="pageSize"
                        layout=" prev, pager, next, sizes, total"
                        :total="total">
                </el-pagination>
            </el-col>

        </div>

        <!-- 编辑弹出框 -->
        <el-dialog title="编辑" :visible.sync="editVisible" width="37%"  >
            <el-form ref="form3" :model="form3"   label-width="125px" label-position="left" padding-left="5%">
                <el-form-item label="计价器厂商名称" prop="factname" :rules="[
                {required:true,message:'计价器厂商名称不能为空'}
                ]">
                    <el-select class="handle-select" v-model="form3.factname" clearable placeholder="请选择"  @change="currentSel">
                        <el-option
                                v-for="item in factnameselectList"
                                :key="item.id"
                                :label="item.factname"
                                :value="item.factname"
                        ></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="计价器型号" prop="jjqtype" :rules="[
                {required:true,message:'计价器型号不能为空'}
                ]">
                    <el-select class="handle-select" v-model="form3.jjqtype" clearable placeholder="请选择">
                        <el-option
                                v-for="item in jjqtypeselectList"
                                :key="item.id"
                                :label="item.jjqtype"
                                :value="item.jjqtype"
                        ></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="价格类别"  prop="pricetype" :rules="[
                {required:true,message:'价格类别不能为空'}
                ]">
                    <el-select class="handle-select" v-model="form3.pricetype" clearable placeholder="请选择">
                        <el-option
                                v-for="item in pricetypeselectList"
                                :key="item.id"
                                :label="item.pricetype"
                                :value="item.pricetype"
                        ></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="物价文件编号" prop="pricefileno" :rules="[
                {required:true,message:'物价文件编号不能为空'}]">
                    <el-input class="handle-input" clearable v-model="form3.pricefileno"></el-input>
                </el-form-item>
                <el-form-item label="版本号" prop="version" :rules="[
                {required:true,message:'版本号不能为空'}
                ]">
                    <el-input class="handle-input" clearable v-model="form3.version"></el-input>
                </el-form-item>

                <el-form-item label="历史物价文件"prop="filename" :rules="[
                {required:true,message:'历史物价文件'}    ]">
                    <el-input class="handle-input" disabled v-model="form3.filename"></el-input>
                </el-form-item>

                <el-form-item label="备注">
                    <el-input type="textarea" rows="5" v-model="form3.memo"></el-input>
                </el-form-item>

                <el-form-item label="更新参数文件"prop="fileid" >
                    <input type="file" @change="getFile($event)"  ref="pathClear" accept=".bin">
                    <button @click="editForm($event)">提交</button>
                </el-form-item>

            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="editVisible = false">取 消</el-button>
                <el-button type="primary"  v-loading="editLoading" @click="saveEdit('form3')">确 定</el-button>
            </span>
        </el-dialog>
        <!--&lt;!&ndash; 交通部审核提示框 &ndash;&gt;-->
        <!--<el-dialog title="提示" :visible.sync="trafficCheckVisible" width="300px" center>-->
            <!--<div class="del-dialog-cnt">审核通过？</div>-->
            <!--<span slot="footer" class="dialog-footer">-->
                <!--<el-button @click="trafficCheckVisible = false">取 消</el-button>-->
                <!--<el-button type="primary" @click="trafficCheckCon">确 定</el-button>-->
            <!--</span>-->
        <!--</el-dialog>-->

        <!--&lt;!&ndash; 财务部审核提示框 &ndash;&gt;-->
        <!--<el-dialog title="提示" :visible.sync="priceCheckVisible" width="300px" center>-->
            <!--<div class="del-dialog-cnt">审核通过？</div>-->
            <!--<span slot="footer" class="dialog-footer">-->
                <!--<el-button @click="priceCheckVisible = false">取 消</el-button>-->
                <!--<el-button type="primary" @click="priceCheckCon">确 定</el-button>-->
            <!--</span>-->
        <!--</el-dialog>-->

        <!--&lt;!&ndash; 计量部审核提示框 &ndash;&gt;-->
        <!--<el-dialog title="提示" :visible.sync="metrologyCheckVisible" width="300px" center>-->
            <!--<div class="del-dialog-cnt">审核通过？</div>-->
            <!--<span slot="footer" class="dialog-footer">-->
                <!--<el-button @click="metrologyCheckVisible = false">取 消</el-button>-->
                <!--<el-button type="primary" @click="metrologyCheckCon">确 定</el-button>-->
            <!--</span>-->
        <!--</el-dialog>-->

        <!-- 删除提示框 -->
        <el-dialog title="提示" :visible.sync="delVisible" width="300px" center>
            <div class="del-dialog-cnt">删除不可恢复，是否确定删除？</div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="delVisible = false">取 消</el-button>
                <el-button type="primary" @click="deleteRow">确 定</el-button>
            </span>
        </el-dialog>
    </div>
</template>



<script>

    export default {
        name: 'ParamtileMgmt',
        data() {
            return {
                url: this.GLOBAL.url,
                // url:"/api",
                file: '',

                canlooklog:false,
                tableData: [],
                logData:[],
                currentPage: 1,
                total: 0,
                page: 1,
                currentPage1: 1,
                total1: 0,
                page1: 1,
                pageSize: 10,
                pageNum:1,
                totalnum:0,
                totalpage:1,
                pageSize1: 10,
                pageNum1:1,
                totalnum1:0,
                totalpage1:1,
                factnameselectList:[],
                pricetypeselectList:[],
                jjqtypeselectList:[],
                multipleSelection1: [],
                multipleSelection2: [],
                usernameselectList:[],
                is_search: false,
                editVisible: false,
                delVisible: false,
                addVisible:false,
                listLoading: false,
                logLoading:false,
                // delete_diabled: false,
                addLoading:false,
                editLoading:false,
                // trafficCheckVisible:false,
                // priceCheckVisible:false,
                // metrologyCheckVisible:false,
                logVisible:false,
                form: {
                    factname: '',
                    carno: '',
                    pricefileno: '',
                    stimel: '',
                    stimer: ''
                },
                form2: {
                    id:'',
                    factid: '',
                    jjqtypeid: '',
                    priceid: '',
                    pricefileno:'',
                    filename:'',
                    version:'',
                    fileinfo:'',
                    fileid:'',
                    memo:''
                },
                form3: {
                    factname: '',
                    jjqtype: '',
                    pricetype: '',
                    id:'',
                    factid: '',
                    jjqtypeid: '',
                    priceid: '',
                    trafficcheck:'',
                    traffictime:'',
                    pricecheck:'',
                    pricetime:'',
                    metrologycheck:'',
                    metrologytime:'',
                    pricefileno:'',
                    stime:'',
                    filename:'',
                    version:'',
                    fileinfo:'',
                    newbj:'',
                    fileid:'',
                    memo:''
                },
                form4:{
                    carno:'',
                    companyname:''
                },
                form5:{
                    taximeters:''
                },
                form6:{
                    username:'',
                    opertype:'',
                    paramid:''
                },
                idx: -1,
                metrologyline:false,
                priceline:false,
                trafficline:false,
                role:[]
            }



        },
        created() {
            this.getData();
            this.getselectcon();
        },
        methods: {
            //改变时
            handleSizeChange(val) {
                this.pageSize = val;
                console.log(this.pageSize);
                this.getData();
            },
            //条目改变时
            handleCurrentChange(val) {
                this.pageNum = val;
                console.log(this.pageNum);
                this.getData();
            },
            //改变时
            handleSizeChange1(val) {
                this.pageSize1 = val;
                console.log(this.pageSize1);
                this.getlog();
            },
            //条目改变时
            handleCurrentChange1(val) {
                this.pageNum1 = val;
                console.log(this.pageNum1);
                this.getlog();
            },
            // created() {
            //     this.getData();
            // },
            //获取列表数据
            getData() {
                this.listLoading = true;

                    this.$axios({
                        method: 'post',
                        url: this.url+"/paramfile/all?pageNum="+this.pageNum+"&pageSize="+this.pageSize,
                        data:this.form
                    }).then((res) => {
                        console.log(res);




                        this.tableData = res.data.list;


                        this.total = res.data.totalnum;
                        this.page = res.data.totalpage;
                        this.listLoading = false;
                    });




                // this.$axios({
                //     method: 'post',
                //     url: "/api/user/userinfopriv"
                // }).then((res) => {
                //     let istrafficline = false;
                //     let ispriceline = false;
                //     let ismetrologyline = false;
                //
                //     this.role = res.data;
                //     console.log( this.role);
                //     this.role.forEach(function (item, index) {
                //         if(item.privilegeid == 5){
                //             istrafficline = true;
                //         }else if(item.privilegeid == 6){
                //             ispriceline = true;
                //         }else if(item.privilegeid == 7){
                //             ismetrologyline = true;
                //         }
                //     });
                //     if(istrafficline){
                //         this.trafficline = istrafficline;
                //     }
                //     if(ispriceline){
                //         this.priceline = ispriceline;
                //     }
                //     if(ismetrologyline){
                //         this.metrologyline = ismetrologyline;
                //     }
                // })

            },
            getselectcon(){

                this.$axios({
                    method: 'post',
                    url: this.url+"/user/usernamelist",
                }).then((res) => {
                    this.usernameselectList = res.data;
                });


                this.$axios({
                    method: 'get',
                    url: this.url+"/fact/list",
                }).then((res) => {
                    this.factnameselectList = res.data;
                });
                this.$axios({
                    method: 'get',
                    url: this.url+"/taximetertype/list",
                }).then((res) => {
                    this.jjqtypeselectList = res.data;
                });
                this.$axios({
                    method: 'get',
                    url: this.url+"/price/list",
                }).then((res) => {
                    this.pricetypeselectList = res.data;
                });

                this.$axios({
                    method: 'post',
                    url: this.url+"/user/userinfopriv"
                }).then((res) => {
                    let canlooklog = false;

                    this.role = res.data;
                    console.log( this.role);
                    this.role.forEach(function (item, index) {
                        if(item.privilegeid == 18){
                            canlooklog = true;
                        }
                    });
                    console.log(canlooklog);
                    if(canlooklog){
                        this.canlooklog = canlooklog;
                    }
                })

            },
            search() {
                this.is_search = true;
                this.getData();
            },
            // handleTraffic(index, row) {
            //     this.idx = index;
            //     this.trafficCheckVisible = true;
            //     const item2 = this.tableData[index];
            //     this.form3.id = item2.id;
            // },
            // handlePrice(index, row) {
            //     this.idx = index;
            //     this.priceCheckVisible = true;
            //     const item2 = this.tableData[index];
            //     this.form3.id = item2.id;
            // },
            // handleMetrology(index, row) {
            //     this.idx = index;
            //     this.metrologyCheckVisible = true;
            //     const item2 = this.tableData[index];
            //     this.form3.id = item2.id;
            // },

            all(){
                this.is_search = false;
                this.form.factname = "";
                this.form.pricetype = "";
                this.form.pricefileno="";
                this.form.stimel = "";
                this.form.stimer = "";
                this.getData();
            },
            alllog(){
                this.is_search = false;
                this.form6.username = "";
                this.form6.opertype = "";
                this.getlog();
            },
            searchlog() {
                this.getlog();
            },
            currentSel(selVal){

                if( this.form.jjqtype !== ''){
                    this.form.jjqtype = '';
                }
                if( this.form3.jjqtype !== ''){
                    this.form3.jjqtype = '';
                }


                if(selVal!==null&&selVal!==''){
                    this.$axios({
                        method: 'post',
                        url: this.url+"/taximetertype/factjjqtype?factname="+selVal,
                    }).then((res) => {

                        //
                        // this.form3.jjqtype = '';
                        this.jjqtypeselectList = res.data;
                    });
                }else {
                    this.$axios({
                        method: 'get',
                        url: this.url+"/taximetertype/list",
                    }).then((res) => {
                        this.jjqtypeselectList = res.data;
                    });
                }

            },

            currentSel_add(selVal){
                if( this.form2.jjqtypeid !== ''){
                    this.form2.jjqtypeid = '';
                }

                console.log(selVal);
                if(selVal!==null&&selVal!==''){
                    this.$axios({
                        method: 'post',
                        url: this.url+"/taximetertype/factidjjqtype?factid="+selVal,
                    }).then((res) => {
                        this.jjqtypeselectList = res.data;
                    });
                }else {
                    this.$axios({
                        method: 'get',
                        url: this.url+"/taximetertype/list",
                    }).then((res) => {
                        this.jjqtypeselectList = res.data;
                    });
                }

            },

            filterTag(value, row) {
                return row.tag === value;
            },
            // handleAdd(index, row) {
            //     this.idx = index;
            //     const item = this.tableData[index];
            //     this.form = {
            //         name: item.name,
            //         date: item.date,
            //         address: item.address
            //     }
            //     this.editVisible = true;
            // },
            handleEdit(index, row) {
                this.idx = index;
                const item = this.tableData[index];
                this.form3 = {
                    factname:item.factname,
                    jjqtype: item.jjqtype,
                    pricetype: item.pricetype,
                    pricefileno:item.pricefileno,
                    version:item.version,
                    id:item.id,
                    filename:item.filename,
                    fileid:item.fileid
                };
                this.editVisible = true;

            },
            looklog(index, row) {
                this.logVisible = true;
                this.logLoading = true;
                this.idx = index;
                console.log(this.tableData[index]);
                const item2 = this.tableData[index];
                this.form6.paramid = item2.id;
                this.getlog();

            },

            getlog(){
                this.$axios({
                    method: 'post',
                    url: this.url+"/paramfile/log?pageNum="+this.pageNum1+"&pageSize="+this.pageSize1,
                    data:this.form6
                }).then((res) => {
                    console.log(res);

                    this.logData = res.data.list;


                    this.total1 = res.data.totalnum;
                    this.page1 = res.data.totalpage;
                    this.logLoading = false;
                });
            },

            handleAdd() {
                this.addVisible = true;
                // this.listLoading1 = true;
                // console.log(this.form4);
                // this.$axios({
                //     method: 'post',
                //     url: this.url+"/carinfo/all",
                //     data:this.form4
                // }).then((res) => {
                //     this.addData1 = res.data;
                //     this.listLoading1 = false;
                // });
                //
                // this.listLoading2 = true;
                // this.$axios({
                //     method: 'post',
                //     url: this.url+"/taximeter/list",
                //     data:this.form4
                // }).then((res) => {
                //     this.addData2 = res.data;
                //     this.listLoading2 = false;
                // });
            },
            handleDelete(index, row) {
                this.idx = index;
                this.delVisible = true;
                const item1 = this.tableData[index];
                this.form3.id = item1.id;
            },
            // handleDelete_add() {
            //     this.delVisible1 = true;
            // },
            // delAll() {
            //     const length = this.multipleSelection.length;
            //     let str = '';
            //     this.del_list = this.del_list.concat(this.multipleSelection);
            //     for (let i = 0; i < length; i++) {
            //         str += this.multipleSelection[i].name + ' ';
            //     }
            //     this.$message.error('删除了' + str);
            //     this.multipleSelection = [];
            // },
            // handleSelectionChange1(val) {
            //     this.multipleSelection1 = val;
            // },
            // handleSelectionChange2(val) {
            //     this.multipleSelection2 = val;
            // },
            addParamfile(form2) {
                this.$refs.form2.validate((valid) => {
                    if (valid) {
                            // console.log(this.form2);
                        this.addLoading = true;
                            this.$axios({
                                method: 'post',
                                url: this.url+"/paramfile/add",
                                data:this.form2
                            }).then((res) => {
                                if(res.data.message=="成功"){
                                    this.$message.success(`添加成功`);
                                    this.addLoading = false;
                                    this.addVisible = false;
                                    this.getData();
                                    this.form2.factid='';
                                    this.form2.jjqtypeid='';
                                    this.form2.priceid='';
                                    this.form2.pricefileno='';
                                    this.form2.version='';
                                    this.form2.fileid='';
                                    this.form2.filename='';
                                    this.form2.memo = '';
                                    this.form2.id='';
                                    this.file='';
                                    this.getFile();
                                }else {
                                    this.$message.error(res.data.message);
                                    this.addLoading = false;
                                }
                            }).catch(function (error) {
                                console.log(error);
                            });

                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                });

                // let str = '';
                // this.del_list = this.del_list.concat(this.multipleSelection);
                // for (let i = 0; i < length; i++) {
                //     str += this.multipleSelection[i].name + ' ';
                // }
                // this.$message.error('删除了' + str);
                // this.multipleSelection = [];
            },
            // 保存编辑
            saveEdit(form3) {

                this.$refs.form3.validate((valid) => {
                    if (valid) {
                        this.editLoading = true;
                        this.$axios({
                            method: 'post',
                            url: this.url+"/paramfile/update",
                            data:this.form3
                        }).then((res) => {
                            console.log(res);
                            if(res.data.message=="成功"){
                                this.$message.success(`修改第 ${this.idx+1} 行成功`);
                                this.editLoading = true;
                                this.editVisible = false;
                                this.getData();
                                this.getFile();
                            }else {
                                this.$message.error(res.data.message);
                                this.editLoading = true;
                            }
                        }).catch(function (error) {
                            console.log(error);
                        });

                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                });

            },
            // 确定删除(增加里的)
            // delete_add() {
            //     const length = this.multipleSelection2.length;
            //     if(length == 0){
            //         this.$message.error('请选择计价器');
            //     }else {
            //         this.form5.taximeters = this.multipleSelection2;
            //         this.delete_diabled = true ;
            //         console.log(this.form2);
            //         this.$axios({
            //             method: 'post',
            //             url: this.url+"/taximeter/deleteall",
            //             data:this.form5
            //         }).then((res) => {
            //             console.log(res);
            //             if(res.data.message=="成功"){
            //                 this.$message.success(`删除成功`);
            //                 this.getData();
            //                 this.delete_diabled = false ;
            //                 this.listLoading2 = true;
            //                 this.delVisible1 = false;
            //                 this.$axios({
            //                     method: 'post',
            //                     url: this.url+"/taximeter/list",
            //                     data:this.form4
            //                 }).then((res) => {
            //                     this.addData2 = res.data;
            //                     this.listLoading2 = false;
            //                 });
            //             }else {
            //                 this.$message.error(res.data.message);
            //                 this.delete_diabled = false ;
            //             }
            //         }).catch(function (error) {
            //             console.log(error);
            //         });
            //
            //     }
            //
            // },
            // trafficCheckCon(){
            //     console.log(this.form3);
            //     this.$axios({
            //         method: 'post',
            //         url: this.url+"/paramfile/trafficsh",
            //         data:this.form3
            //     }).then((res) => {
            //         console.log(res);
            //         if(res.data.message=="成功"){
            //             this.$message.success('审核成功');
            //             this.trafficCheckVisible = false;
            //             this.getData();
            //         }else {
            //             this.$message.error(res.data.message);
            //         }
            //     }).catch(function (error) {
            //         console.log(error);
            //     });
            // },
            // priceCheckCon(){
            //     console.log(this.form3);
            //     this.$axios({
            //         method: 'post',
            //         url: this.url+"/paramfile/pricesh",
            //         data:this.form3
            //     }).then((res) => {
            //         console.log(res);
            //         if(res.data.message=="成功"){
            //             this.$message.success('审核成功');
            //             this.priceCheckVisible = false;
            //             this.getData();
            //         }else {
            //             this.$message.error(res.data.message);
            //         }
            //     }).catch(function (error) {
            //         console.log(error);
            //     });
            // },
            // metrologyCheckCon(){
            //     console.log(this.form3);
            //     this.$axios({
            //         method: 'post',
            //         url: this.url+"/paramfile/metrologysh",
            //         data:this.form3
            //     }).then((res) => {
            //         console.log(res);
            //         if(res.data.message=="成功"){
            //             this.$message.success('审核成功');
            //             this.metrologyCheckVisible = false;
            //             this.getData();
            //         }else {
            //             this.$message.error(res.data.message);
            //         }
            //     }).catch(function (error) {
            //         console.log(error);
            //     });
            // },
            // 确定删除
            deleteRow(){
                this.$axios({
                    method: 'post',
                    url: this.url+"/paramfile/delete/"+this.form3.id.toString(),
                }).then((res) => {
                    console.log(res);
                    if(res.data.message=="成功"){
                        this.$message.success('删除成功');
                        this.delVisible = false;
                        this.getData();
                    }else {
                        this.$message.error(res.data.message);
                    }
                }).catch(function (error) {
                    console.log(error);
                });

            },
            getFile(event) {
                // this.file = event.target.files[0];
                // console.log(this.file);

                if(event ==null){
                    this.$refs. pathClear.value =''
                }else { this.file = event.target.files[0];}
            },
            submitForm(event) {
                event.preventDefault();
                let formData = new FormData();
                formData.append('tablename', 'paramfile');
                formData.append('ownerid', uuid());
                formData.append('fileid', uuid());
                formData.append('file', this.file);

                let config = {
                    headers: {
                        'Content-Type': 'multipart/form-data'
                    }
                }

                console.log(formData);
                this.$axios.post(this.url+'/files',formData,config)
                .then((res) => {
                    console.log(res);
                    if(res.data.message=="上传成功"){
                        this.$message.success('上传成功');
                        this.form2.fileid = formData.get('fileid');
                        this.form2.id = formData.get('ownerid');
                    }else {
                        this.$message.error(res.data.message);
                    }
                }).catch(function (error) {
                    console.log(error);
                });
            },
            editForm(event) {
                event.preventDefault();
                let formData = new FormData();
                formData.append('tablename', 'paramfile');
                formData.append('ownerid', this.form3.id);
                formData.append('fileid', uuid());
                formData.append('file', this.file);

                let config = {
                    headers: {
                        'Content-Type': 'multipart/form-data'
                    }
                }

                console.log(formData);
                this.$axios.post(this.url+'/files',formData,config)
                    .then((res) => {
                        console.log(res);
                        if(res.data.message=="上传成功"){
                            this.$message.success('上传成功');
                            this.form3.fileid = formData.get('fileid');
                        }else {
                            this.$message.error(res.data.message);
                        }
                    }).catch(function (error) {
                    console.log(error);
                });
            }


         }
        //     // 获取uuid


    }
    function uuid() {
        var s = [];
        var hexDigits = "0123456789abcdef";
        for (var i = 0; i < 32; i++) {
            s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
        }
        s[14] = "4";  // bits 12-15 of the time_hi_and_version field to 0010
        s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1);  // bits 6-7 of the clock_seq_hi_and_reserved to 01
        s[8] = s[13] = s[18] = s[23] = "-";

        var uuid = s.join("");
        return uuid;
    }

</script>

<style>
    .handle-box {
        margin-bottom: 20px;
    }

    .handle-select {
        width: 300px;
    }
    .handle-add-select {
        width: 200px;
    }
    .handle-input {
        width: 300px;
        display: inline-block;
    }
    .handle-add-input {
        width: 200px;
        display: inline-block;
    }
    .del-dialog-cnt{
        font-size: 16px;
        text-align: center
    }
    .table{
        margin-top: 10px;
        width: 100%;
        font-size: 14px;
    }
    .red{
        color: #ff0000;
    }
    .mr10{
        margin-right: 10px;
        width: 80px;
    }
    .customWidth{
        width:80%;
    }

</style>
